//
//  CPSCCouponCommonVC.m
//  CollTest
//
//  Created by codew on 10/22/21.
//

#import "CPSCCouponCommonVC.h"
#import "CPSCTableViewCouponCell.h"
#import "CPSCCouponCell.h"

#import "CPSCUnuseCouponCell.h"

@interface CPSCCouponCommonVC ()<UITableViewDelegate, UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSMutableArray * dataArray;
@property (nonatomic, assign) NSInteger page;

@end

static NSString * CPSCCouponCellIdentifier = @"CPSCCouponCell";

static NSString * CPSCTableViewCouponCellIdentifier = @"CPSCTableViewCouponCell";

static NSString * CPSCUnuseCouponCellIdentifier = @"CPSCUnuseCouponCell";

@implementation CPSCCouponCommonVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self setUpMainUI];
}

- (void)setUpMainUI
{
    
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    
}

#pragma mark - <UITableViewDelegate, UITableViewDataSource>
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 20;self.dataArray.count;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        
//    CPSCTableViewCouponCell  * cell = [tableView dequeueReusableCellWithIdentifier:CPSCTableViewCouponCellIdentifier];
//
//    if (!cell) {
//
//        [tableView registerNib:[UINib nibWithNibName:CPSCTableViewCouponCellIdentifier bundle:nil] forCellReuseIdentifier:CPSCTableViewCouponCellIdentifier];
//
//        cell = [tableView dequeueReusableCellWithIdentifier:CPSCTableViewCouponCellIdentifier];
//    }
//
////    cell.backgroundColor = WTARTRandomColor;
//    return cell;
    
    CPSCUnuseCouponCell  * cell = [tableView dequeueReusableCellWithIdentifier:CPSCUnuseCouponCellIdentifier];
    
    if (!cell) {
        
        [tableView registerNib:[UINib nibWithNibName:CPSCUnuseCouponCellIdentifier bundle:nil] forCellReuseIdentifier:CPSCUnuseCouponCellIdentifier];
        
        cell = [tableView dequeueReusableCellWithIdentifier:CPSCUnuseCouponCellIdentifier];
    }
    
    cell.backgroundColor = kCPSCRandomColor;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    CGFloat cellHeight = [CPSCUnuseCouponCell heightCell];
            
    return cellHeight;
}



@end
